package cn.kuang.controller;

import cn.kuang.pojo.ArticleContent;
import cn.kuang.service.ArricleContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 徽州大都督
 * @date 2020/7/25
 */
@RestController
@RequestMapping("content")
public class ArricleContentController {

    @Autowired
    ArricleContentService arricleContentService;

    @PostMapping("addContent")
    public String addContent(@RequestBody ArticleContent articleContent){

        System.out.println (articleContent);

        int row=arricleContentService.addContent(articleContent);
        /*System.out.println (tid);
        System.out.println (username);*/

        if (row>0){
            return "success";
        }else{
            return "error";
        }

    }



    @GetMapping("findPage/{page}/{size}/{tid}")
    public List<ArticleContent> findPage(@PathVariable("page")Integer page, @PathVariable("size")Integer size,@PathVariable("tid")String tid){

        //System.out.println (tid);

        //System.out.println (page);
        //System.out.println (size);
        List<ArticleContent> ContentList =arricleContentService.findPage(page,size,tid);

        //System.out.println (page);
        //System.out.println (size);
        //System.out.println (tid);
        return ContentList;
    }
}
